// eslint-disable-next-line import/prefer-default-export
export function formatUTCTime(value: string) {
  if (value) {
    const date = new Date(value);
    const y = date.getFullYear();
    let MM: string | number = date.getMonth() + 1;
    MM = MM < 10 ? `0${MM}` : MM;
    let d: string | number = date.getDate();
    d = d < 10 ? `0${d}` : d;
    let h: string | number = date.getHours();
    h = h < 10 ? `0${h}` : h;
    let m: string | number = date.getMinutes();
    m = m < 10 ? `0${m}` : m;
    let s: string | number = date.getSeconds();
    s = s < 10 ? `0${s}` : s;
    return `${y}-${MM}-${d} ${h}:${m}:${s}`;
  }
  return ' ';
}

export function formatUTCDate(value: string) {
  if (value) {
    const date = new Date(value);
    const y = date.getFullYear();
    let MM: string | number = date.getMonth() + 1;
    MM = MM < 10 ? `0${MM}` : MM;
    let d: string | number = date.getDate();
    d = d < 10 ? `0${d}` : d;
    return `${y}-${MM}-${d}`;
  }
  return ' ';
}

export function currentLocaleTime() {
  const date = new Date();

  const year = date.getFullYear().toString().padStart(4, '0');
  const month = (date.getMonth() + 1).toString().padStart(2, '0');
  const day = date.getDate().toString().padStart(2, '0');
  const hour = date.getHours().toString().padStart(2, '0');
  const minute = date.getMinutes().toString().padStart(2, '0');

  const formattedDate = `${year}${month}${day}${hour}${minute}`;
  return formattedDate;
}
